<template>
    {{ message }}
    <button @click="changeName">changeName</button>
</template>

<script setup lang="ts">

import { customRef }  from 'vue'

function myFn<T>( value:T ){
  return customRef( ( trank , trigger ) => {
    return {
      get(){
        trank()
        console.log(value + 'get');
        return value 
      },
      set( newValue : T){
        value = newValue
        console.log(value + 'set');
        trigger()
      }
    }
  })
}

let message = myFn<string>("港龙")

const changeName = () => {
  message.value = "猪猪"
}

</script>

<style lang='scss' scoped>

</style>
